package LeetCode;

import java.util.Scanner;

public class Main027 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int size = sc.nextInt();
        System.out.println("请输入数组长度");
        int[] nums = new int[size];
        for (int i = 0; i < nums.length; i++) {
            int a = sc.nextInt();
            nums[i] = a;
        }

        System.out.println("请输入移除的值");
        int val = sc.nextInt();
        System.out.println(removeElement(nums, val));
    }


    public static int removeElement(int[] nums, int val) {
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != val) {
                nums[count] = nums[i];
                count++;
            }
        }
        return count;
    }
}